package cn.usian.controller;

import cn.usian.common.R;
import cn.usian.entity.Dish;
import cn.usian.entity.DishDto;
import cn.usian.service.DishService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/dish")
public class DishController {
    @Resource
    private DishService dishService;
    /*
    * 分页
    * */
    @GetMapping("/page")
    public R<Page<Dish>> page(Integer page, Integer pageSize, String name){
        return dishService.page(page, pageSize, name);
    }

    //批量删除
    @DeleteMapping
    public  R del(long[] ids){
        dishService.del(ids);
        return  R.success("删除成功");
    }

   //批量状态
    @PostMapping("status/{status}")
    public R status(@PathVariable("status")Integer status,long[] ids){
        return dishService.status(status,ids);
    }
  /*
    @PostMapping
    public R save(@RequestBody DishDto dishDto, HttpSession session){
        //1.补全创建人与修改人
        Long empId=(Long) session.getAttribute("employee");
        dishDto.setCreateUser(empId);
        dishDto.setUpdateUser(empId);
        dishService.save(dishDto);
        return R.success("添加成功");
    }*/
}
